package com.yuantu.judiciary.controller;

import com.yuantu.judiciary.common.Response;
import com.yuantu.judiciary.common.ResponseFactory;
import com.yuantu.judiciary.model.form.IdentifyAuthForm;
import com.yuantu.judiciary.model.vo.IdentifyAuthResVO;
import com.yuantu.judiciary.service.IIdentityAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 身份认证管理
 *
 * @author syw
 * @since 2023-12-26
 **/
@RestController
@RequestMapping(value = "/identity-auth")
@Api(tags = "身份认证管理")
@RequiredArgsConstructor
public class IdentityAuthController extends BaseController {

    private final IIdentityAuthService identityAuthService;

    @ApiOperation(value = "身份认证-支付宝小程序")
    @PostMapping("/ali-applet")
    public Response<IdentifyAuthResVO> getIdentifyAuthByAliApplet(@RequestBody @Validated IdentifyAuthForm form) {
        Long accountId = getLoginAccount().getAccountId();
        return ResponseFactory.okResponse(identityAuthService.getIdentifyAuthByAliApplet(accountId, form));
    }

    @ApiOperation(value = "身份验证结果-支付宝小程序")
    @GetMapping("/result/ali-applet")
    public Response<Boolean> getIdentifyAuthResultByAliApplet() {
        Long accountId = getLoginAccount().getAccountId();
        return ResponseFactory.okResponse(identityAuthService.getIdentifyAuthResultByAliApplet(accountId));
    }

}
